<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <link rel="stylesheet" href="/static/layui/css/layui.css"  media="all">
</head>
<body>

  <div style="padding: 10px;">

    <div class="layui-fluid">
      <form class="layui-form" id="ajaxform" onsubmit="return false">
        <input type="hidden" value="{$id}" name="id" />

            {foreach $nav as $vo} 
              <div class="layui-form-item">
                <label class="layui-form-label">{$vo.title}</label>
                <div class="layui-input-block">
                  {foreach $vo.nav_list as $v}
                  {if condition="$v.has==1"}
                  <input name="nav[]" title="{$v.title}" type="checkbox" checked="checked" value="{$v.id}">
                  {else /}<input name="nav[]" title="{$v.title}" type="checkbox"  value="{$v.id}">
                  {/if}
                  <div class="layui-unselect layui-form-checkbox">
                    <span>{$v.title}</span><i class="layui-icon layui-icon-ok"></i>
                  </div>
                  {/foreach}
                </div>
              </div>
            {/foreach}
              <!-- <div class="layui-form-item">
                <label class="layui-form-label">{$other.title}</label>
                <div class="layui-input-block">
                  {foreach $other.nav_list as $v}
                  {if condition="$v.has==1"}
                  <input name="other[]" title="{$v.title}" type="checkbox" checked="checked" value="{$v.id}">
                  {else /}<input name="other[]" title="{$v.title}" type="checkbox"  value="{$v.id}">
                  {/if}
                  <div class="layui-unselect layui-form-checkbox">
                    <span>{$v.title}</span><i class="layui-icon layui-icon-ok"></i>
                  </div>
                  {/foreach}
                </div>
              </div> -->
          <div class="layui-form-item">
            <div class="layui-input-block">
              <button class="layui-btn" lay-filter="formDemo" onclick="ajax()">提交</button>
            </div>
          </div>
      </form>
    </div>   
  </div>     
<script src="/static/layui/layui.js" charset="utf-8"></script>
<!-- 注意：如果你直接复制所有代码到本地，上述js路径需要改成你本地的 -->
<script src="/static/js/jquery.min.js"></script>
  <script>
    //JavaScript代码区域
    layui.use(['element','form'], function(){
      var element = layui.element;
      var form = layui.form; 
    });

  function ajax(el){
    var post_data = $("#ajaxform").serialize();
    // post_data = JSON.stringify(post_data);
    // console.log(post_data);
    
    $.ajax({
            url:"{:url('admin/authority/edit')}",
            type:"POST",
            data:post_data,
            success:function(ret){
                if (ret.code == 0) {
                  layer.msg('操作成功');
                  window.location.reload();
                }
                if (ret.code == 1) {
                    layer.msg(ret.msg);
                }
            }
        });
  }
  </script>
</body>
</html>